﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Perceiveit.Xml;
using System.Drawing;
using System.Data;

namespace Perceiveit.Xml.Tests.Concrete
{
    public class Root : XRootEntity
    {
        public const string XmlNamespace = "http://schemas.perceiveit.co.uk/xmlobject/sample.xsd";

        private static XProperty<int> _integer = XProperty.Attribute<int>("integer");
        private static XProperty<string> _string = XProperty.Attribute<string>("string");
        private static XProperty<bool> _bool = XProperty.Attribute<bool>("bool");
        private static XProperty<DbType> _dbenum = XProperty.Attribute<DbType>("db-enum");
        private static XProperty<Guid> _guid = XProperty.Attribute<Guid>("guid");
        private static XProperty<byte> _byte = XProperty.Attribute<byte>("byte");
        private static XProperty<char> _char = XProperty.Attribute<char>("char");
        private static XProperty<DateTime> _datetime = XProperty.Attribute<DateTime>("datetime");
        private static XProperty<decimal> _decimal = XProperty.Attribute<decimal>("decimal");
        private static XProperty<double> _double = XProperty.Attribute<double>("double");
        private static XProperty<float> _float = XProperty.Attribute<float>("float");
        private static XProperty<Color> _color = XProperty.Attribute<Color>("color");
        private static XProperty<long> _long = XProperty.Attribute<long>("long");
        private static XProperty<Point> _pt = XProperty.Attribute<Point>("point");
        private static XProperty<sbyte> _sbyte = XProperty.Attribute<sbyte>("sbyte");
        private static XProperty<short> _short = XProperty.Attribute<short>("short");
        private static XProperty<TimeSpan> _timespan = XProperty.Attribute<TimeSpan>("timespan");
        private static XProperty<uint> _uint = XProperty.Attribute<uint>("uint");
        private static XProperty<ulong> _ulong = XProperty.Attribute<ulong>("ulong");
        private static XProperty<Uri> _uri = XProperty.Attribute<Uri>("uri");
        private static XProperty<ushort> _ushort = XProperty.Attribute<ushort>("ushort");
        private static XProperty<Uri> _icon = XProperty.Text<Uri>("icon");

        private static XProperty<LocalString> _name = XProperty.Complex<LocalString>("name", XmlNamespace);
        private static XProperty<LocalString> _desc = XProperty.Complex<LocalString>("description", XmlNamespace);
        private static XProperty<ComplexChildDictionary> _complex = XProperty.Complex<ComplexChildDictionary>("complex-child-list", XmlNamespace);
        private static XPropertyList<SimpleChild> _simple = XProperty.List<SimpleChild>("simple-child", XmlNamespace, "simple");
        private static XProperty<DefaultListWrapper> _wrapper = XProperty.Complex<DefaultListWrapper>("default-list", XmlNamespace);


        public int IntegerValue
        {
            get { return _integer.GetValue(this); }
            set { _integer.SetValue(this, value); }
        }

        public string StringValue
        {
            get { return _string.GetValue(this); }
            set { _string.SetValue(this, value); }
        }
        
        public bool BoolValue
        {
            get { return _bool.GetValue(this); }
            set { _bool.SetValue(this, value); }
        }

        public Guid GuidValue
        {
            get { return _guid.GetValue(this); }
            set { _guid.SetValue(this, value); }
        }

        public DbType DbTypeValue
        {
            get { return _dbenum.GetValue(this); }
            set { _dbenum.SetValue(this, value); }
        }

        public byte ByteValue
        {
            get { return _byte.GetValue(this); }
            set { _byte.SetValue(this, value); }
        }

        public char CharValue
        {
            get { return _char.GetValue(this); }
            set { _char.SetValue(this, value); }
        }

        public DateTime DateValue
        {
            get { return _datetime.GetValue(this); }
            set { _datetime.SetValue(this, value); }
        }

        public Decimal DecimalValue
        {
            get { return _decimal.GetValue(this); }
            set { _decimal.SetValue(this, value); }
        }

        public Double DoubleValue
        {
            get { return _double.GetValue(this); }
            set { _double.SetValue(this, value); }
        }

        public float FloatValue
        {
            get { return _float.GetValue(this); }
            set { _float.SetValue(this, value); }
        }

        public Color ColorValue
        {
            get { return _color.GetValue(this); }
            set { _color.SetValue(this, value); }
        }

        public long LongValue
        {
            get { return _long.GetValue(this); }
            set { _long.SetValue(this, value); }
        }

        public Point Point
        {
            get { return _pt.GetValue(this); }
            set { _pt.SetValue(this, value); }
        }

        public sbyte SByteValue
        {
            get { return _sbyte.GetValue(this); }
            set { _sbyte.SetValue(this, value); }
        }

        public short ShortValue
        {
            get { return _short.GetValue(this); }
            set { _short.SetValue(this, value); }
        }

        public TimeSpan TimeSpanValue
        {
            get { return _timespan.GetValue(this); }
            set { _timespan.SetValue(this, value); }
        }

        public uint UIntValue
        {
            get { return _uint.GetValue(this); }
            set { _uint.SetValue(this, value); }
        }

        public ulong ULongValue
        {
            get { return _ulong.GetValue(this); }
            set { _ulong.SetValue(this, value); }
        }

        public Uri UriValue
        {
            get { return _uri.GetValue(this); }
            set { _uri.SetValue(this, value); }
        }

        public ushort UShortValue
        {
            get { return _ushort.GetValue(this); }
            set { _ushort.SetValue(this, value); }
        }

        public Uri IconText
        {
            get { return _icon.GetValue(this); }
            set { _icon.SetValue(this, value); }
        }

        public LocalString LocalName
        {
            get { return _name.GetValue(this); }
            set { _name.SetValue(this, value); }
        }

        public ComplexChildDictionary Complex
        {
            get { return _complex.GetValue(this); }
            set { _complex.SetValue(this, value); }
        }

        public XList<SimpleChild> SimpleChildren
        {
            get 
            {
                XList<SimpleChild> list = _simple.GetValue(this);
                if (null == list)
                {
                    list = _simple.Create();
                    _simple.SetValue(this, list);
                }
                return list;
            }
        }


        public DefaultListWrapper DefaultListWrapper
        {
            get
            {
               return _wrapper.GetValue(this);
            }
            set
            {
                _wrapper.SetValue(this, value);
            }
        }

        public Root()
            : base(System.Xml.Linq.XName.Get("root", XmlNamespace))
        {
        }
    }
}
